package es.bwain.xprt.test;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import es.bwain.balls.User;
import es.bwain.xprt.action.Action;

public class LoginAction extends Action {

	private String username;
	private String password;
	
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) {
		
		if ("rpastort".equals(this.getUsername()) && "1234".equals(this.getPassword())) {
			User user = new User();
			user.setId(1L);
			user.setName("Ricardo");
			user.setSurname("Pastor");
			user.setUsername("rpastort");
			
			this.putStickyBall("user", user);
			
			this.setRedirectTo("/test/doItBetter");
		} else {
			this.setRedirectTo("/test/loginScreen");
		}
		
	}

}
